--处理obj文件的section数据
--查找段
assert(arg[1],"input file is not exits");
for k,v in ipairs(arg)do
    if(v=='-h')then
        hack = arg[k+1];
    end
end
if(hack)then
    hack = io.open(hack,"w+");
end
local file = io.popen(string.format("arm-none-eabi-objdump -h %s",arg[1]));
local txt = file:read('*a');
for idx,addr in string.gmatch(txt,"(%d)%s*%.(0x%x+)") do
    --print(idx,addr);
    io.stderr:write("find  ",idx,"  ",addr,'\n');
    --导出文件
    os.execute(string.format("arm-none-eabi-objcopy -j .%s -O binary %s .%s.bin",addr,arg[1],addr));
    --os.execute(string.format('arm-none-eabi-objcopy -R .%s %s',addr,arg[1]))
    if(hack)then
        hack:write(string.format([[
restore .%s.bin binary %s
]],addr,addr));
    end
end
